package com.desay.pangoo.itmt.entity;

import java.io.Serializable;
import java.util.Objects;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.Data;

/**
 * roadMap_yearQuarter
 * 
 * @author uidq1163
 *
 */
@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name = "tech_online_review_files")
@Data
public class TechOnlineReviewFileEntity extends BaseEntity implements Serializable {

	private static final long serialVersionUID = 2978332743756611293L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", columnDefinition = "bigint COMMENT '主键'")
	private Long id;

	@Column(name = "file_path", nullable = false, columnDefinition = "text COMMENT '文件保存在服务器上的全路径'")
	private String filePath;

	@Column(name = "file_type", nullable = true, columnDefinition = "varchar(50) COMMENT '文件用途'")
	private String fileType;

	@Column(name = "file_name", nullable = false, columnDefinition = "varchar(255) COMMENT '文件实际名称'")
	private String fileName;

	@ManyToOne(fetch = FetchType.EAGER, optional = true)
	@JoinColumn(name = "tech_online_review_id")
	@JsonIgnoreProperties({ "workGroup", "files", "parent", "children" })
	private TechOnlineReviewEntity techOnlineReview;

	@ManyToOne(fetch = FetchType.EAGER, optional = true)
	@JoinColumn(name = "tech_project_status_id")
	@JsonIgnoreProperties({ "techProject", "files" })
	private TechProjectStatusEntity techProjectStatus;

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		TechOnlineReviewFileEntity other = (TechOnlineReviewFileEntity) obj;
		if (id == null) {
			if (other.id != null) {
				return false;
			}
		} else if (!id.equals(other.id)) {
			return false;
		}
		return true;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + Objects.hash(filePath, techOnlineReview);
		return result;
	}

}
